<?php
/**
 * Filename:	GPieChart.php
 * Author:		Manish Sinha
 * Date:		22/01/09
 * Details:		This file inherits GAbstractChart and add PieChart
 * 				specific properties to the class
 * Project:		GeeCharts
 */

require_once("GAbstractChart.php");

class GPieChart extends GAbstractChart
{
	//	An array to hold Labels of the chart
	private $labels = array();
	
	private $pieType = array(	"2D" => "p",
								"3D" => "p3",
								"CONC" => "pc");
	
	public function __construct($x,$y,$type = "3D")
	{
		parent::__construct($x,$y);
		$this->info['cht'] = "cht=".$this->pieType[$type];
	}
	
	public function ChartOrientation($angle)
	{
		$this->info['chp'] = "chp=".$angle*(3.14159265358979323846/360);
	}
	
	//	Appends the Label to the chart
	public function AddLabels($templabel)
	{
		if(is_array($templabel))
		{
			//	The Array in which label is stored
			$this->labels = array_merge($this->labels, $templabel);
			
			//	Create the Chart Label Property
			$this->info['chl'] = "chl=".implode("|", $this->labels);
		}
		
		return $this;
	}
	
	// Returns the label of the Charts
	public function GetLabels()
	{
		return $this->labels;
	}
	
	public function GetURI()
	{
		$tempdata = array();
		foreach($this->data as $dataset)
		{
			if(is_array($dataset))
				array_push($tempdata,implode(",",$dataset));
		}
		$this->info['chd'] = "chd=t:".implode("|", $tempdata);
		
		return "http://chart.apis.google.com/chart?".implode("&amp;",$this->info);
		
	}
}
?>
